package com.handa.documentManager.feign;

import com.handa.common.entity.Response;
import com.handa.common.entity.SysUser;
import com.handa.common.exception.ServiceException;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class AdminFeignClientService {
    @Resource
    private AdminFeignClient adminFeignClient;

    public SysUser getSysUserByName(String username) {
        Response<SysUser> sysUserResp = adminFeignClient.getUserByUserName(username);
        if (sysUserResp.getCode() != 200) {
            throw new ServiceException("获取系统用户失败： \n" + sysUserResp.getMsg());
        }

        return sysUserResp.getData();
    }

    public String getConfigByName(String configName) {
        Response<String> systemConfigResp = adminFeignClient.getConfigByName(configName);
        if (systemConfigResp.getCode() != 200) {
            throw new ServiceException("获取系统配置失败： \n" + systemConfigResp.getMsg());
        }

        return systemConfigResp.getData();
    }

}
